package com.bcqn.enums;

public enum MessageType {
    /**
     * 帖子点赞
     */
    POST_LIKE(1, "帖子点赞"),
    /**
     * 帖子评论
     */
    POST_COMMENT(2, "帖子评论"),
    /**
     * 评论点赞
     */
    COMMENT_LIKE(3, "评论点赞"),
    /**
     * 评论回复
     */
    COMMENT_REPLY(4, "评论回复");

    private final Integer value;
    private final String title;

    MessageType(Integer value, String title) {
        this.value = value;
        this.title = title;
    }

    public Integer value() {
        return value;
    }

    public Integer getValue() {
        return value;
    }

    public String getTitle() {
        return title;
    }

    public String getTitle(Integer value) {
        return of(value).title;
    }

    public static MessageType of(final Integer value) {
        for (MessageType e : MessageType.values()) {
            if (e.value != null && e.value.equals(value)) {
                return e;
            }
        }
        return null;
    }

    public static MessageType nameOf(final String title) {
        for (MessageType e : MessageType.values()) {
            if (e.title.equals(title.trim())) {
                return e;
            }
        }
        return null;
    }


    @Override
    public String toString() {
        return this.title;
    }
}
